Continued Fractions via Euclid's Algorithm

The main reason for writing GCD II was not just to employ the Euclidean algorithm, but to set up the javascript to construct continuing fractions. The Euclidean algorithm for finding the GCD of two integers leads immediately to an important method for representing the quotient of two integers as a composite fraction. Applied to the numbers 840 and 611, for example, the Euclidean algorithm yields the series of equations,

840 = 1 x 611 + 229 , 611 = 2 x 229 + 153 , 229 = 1 x 153 + 76 , 153 = 2 x 76 + 1

which show, incidentally, that (840, 611) = 1. From these equations we may derive the following expressions:

840 611 = 1 + 229 611 = 1 + 1 611 229
611 229 = 2 + 153 229 = 2 + 1 229 153
229 153 = 1 + 76 153 = 1 + 1 153 76
153 76 = 2 + 1 76

On combining these equations we obtain the development of the rational number 840/611 in the form

840 611 = 1 + 1 2 + 1 1 + 1 2 + 1 76

An expression of the form

a = a0 + 1 a1 + 1 a2 + 1 a3 + 1 an

where the a's are positive integers, is called a continued fraction. The Euclidean algorithm gives us a method for expressing any rational number in this form.

The calculator returns the continued fraction for any two selected numbers using the Euclidean algorithm. To use the calculator simply enter the two numbers. Then hit the button to calculate the list.

The order of entry is important. The numerator should be entered in the top box and the denominator in the bottom box.




Enter two numbers and hit the button:




Refresh between calculations to make sure global variables are reset.